<?php

class Core_Component_System_Business_Website {

    public function modifyWebsiteStatus($ids, $status){
        $ids = Soul_Util_Array::pack($ids);
        $updator = App::getModel('system/website');
        switch($status){
            case CONSTANT_STATUS_FORBIDDEN:
                $updator->set('status', CONSTANT_STATUS_FORBIDDEN)
                        ->condition('status', CONSTANT_STATUS_PUBLISHED);
                break;
            case CONSTANT_STATUS_REMOVED:
                $updator->set('status', CONSTANT_STATUS_REMOVED)
                        ->condition('status', CONSTANT_STATUS_PUBLISHED);
                break;
            case CONSTANT_STATUS_DELETED:
                $updator->set('status', CONSTANT_STATUS_DELETED)
                        ->condition('status', CONSTANT_STATUS_REMOVED);
                break;
        }
        $updator->condition('id', $ids, 'in')->execute();
    }   
    
    public function setDefaultWebsite($id){
        $updator = App::getModel('system/website')->getUpdate();
        $updator->set('is_default', 0)->execute();
        $updator->resetValue()->set('is_default', 1)->condition('id', $id)->execute();
    }    
}